from flask import Flask, request, make_response, render_template
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm
from wtforms import StringField,SubmitField
from wtforms.validators import DataRequired

class NameForm(FlaskForm):
    name = StringField('What is your name?', validators=[DataRequired()])
    submit = SubmitField('submit')

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
bootstrap = Bootstrap(app)

@app.route('/',methods=['GET','POST'])
def index():
    form = NameForm()
    name = None

    if form.validate_on_submit():
        name = form.name.data
        form.name.data = ''

    return render_template('index_bd.html',form=form,name=name)

@app.route('/user/<name>')
def hello(name):
    return f'hello {name}'



if __name__ == '__main__':
    app.run(debug=True)